package cn.zymall.goods.controller;

import cn.zymall.common.controller.crud.BaseController;
import cn.zymall.common.model.Collect;
import cn.zymall.goods.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lxh
 * @Description 收藏控制层
 * @date 2020/8/27 20:56
 * @Classname CollectController
 **/
@RestController
@RequestMapping("/collect")
public class CollectController extends BaseController<CollectService,Collect> {


	@Autowired
	private CollectService collectService;

	/**
	 *收藏商品
	 * @param collect
	 * @return
	 */
	@PostMapping("/addMyCollect")
	public void addMyCollect(Collect collect){
		collectService.addMyCollect(collect);
	}


	/**
	 * 取消收藏
	 * @param collect
	 */
	@PostMapping("deleteMyCollect")
	public void deleteMyCollect(Collect collect){
		collectService.deleteMyCollect(collect);
	}

	/**
	 * 判断是否收藏了此商品
	 * @param collect
	 * @return
	 */
	@GetMapping("/getCollectCount")
	public Integer getCollectCount(Collect collect){
		return collectService.getCollectCount(collect);
	}

}
